"""A tool for parsing configuration files
"""
import os

# 获取前一级路径
# BASE_PATH = os.path.dirname(os.path.dirname(__file__))

# 获取当前路径
BASE_PATH = os.path.dirname(__file__)

class Config:
    UART_BAUDRATE = 115200
    UART_TIMEOUT = 3

    CAR_TASK = "TASK"
    IMG_REC = "IMG_REC"


    SOCKET_NETWORK_CARD = "wlan0"
    SOCKET_PORT = "60000"
    SOCKET_HOST_IP = "192.168.43.100"
    
    LOG_LEVEL_STDOUT = "info"
    LOG_LEVEL_FILE = "info"
    LOG_SAVE_FLODER = os.path.join(BASE_PATH, "bkrc_car_log")
    
    IPC_CAMERA_HEAD = "rtsp://admin:888888@"
    IPC_CAMERA_IP = "192.168.16.100"
    IPC_CAMERA_PORT = "10554"
    IPC_CAMERA_PLAYADDER = "/tcp/av0_1"

    USB_CAMERA_INDEX= "/dev/video1"
    CLINET_MODE = "uart"

class DevelopmentConfig(Config):
    """开发者模式"""
    ENV = "development"
    DEBUG = True
    DEVELOPMENT = True

    SQLALCHEMY_DATABASE_URI = os.environ.get(
        "DEV_DATABASE_URI", "sqlite:///" + os.path.join(BASE_PATH, "data-dev.sqlite")
    )

class ProductionConfig(Config):
    """生产环境"""
    ENV = "production"
    DEBUG = False
    DEVELOPMENT = False

    SQLALCHEMY_DATABASE_URI = os.environ.get(
        "DATABASE_URI", "sqlite:///" + os.path.join(BASE_PATH, "data.sqlite")
    )

config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
}
